<template>
	<view class="ys">

		<view class="listbox" v-for="(item,index) in list" :key="index" @click="toPage('./detail?id='+ item.id)">
			<view class="listitem">
				<view class="top">
					<view class="textleft">
						问题标题：{{item.title}}
					</view>
					<view class="righttips" v-if="item.status.value == 0">
						未回复
					</view>
					<view class="righttips green" v-else>
						已回复
					</view>
				</view>
				<view class="time">
					{{item.add_time | formatTime}}
				</view>
			</view>
		</view>
		<view class="no-list" v-if="list == ''">
			<image src="/static/index/nolist.png" mode="widthFix"></image>
			- 暂无数据 -
		</view>
		<button @click="toPage('./uploads')" class="search">立即反馈</button>
	</view>
</template>

<script>
	import {
		feedbackList
	} from "@/api/api.js"
	export default {
		data() {
			return {
				feedback: {},
				list: [],
				page: 1,
				last_page: 1,
			}
		},
		onLoad() {
			this.FeedBack()
		},
		onReachBottom() {
			if (this.page < this.last_page) {
				this.page++
				this.FeedBack()
			}
		},
		methods: {
			FeedBack() {
				feedbackList({
					page: this.page
				}).then(res => {
					this.list = this.list.concat(res.data.data)
					this.last_page = res.data.last_page
				})
			},
			toPage(url) {
				uni.navigateTo({
					url
				})
			}
		}
	}
</script>

<style lang="scss">
	.search {
		position: fixed;
		font-size: 14px;
		background: $uni-bg-color;
		color: #fff;
		border-radius: 20px;
		width: 30%;
		bottom: 20px;
		left: 35%;
		box-shadow: 0 0 8px $uni-bg-color;
	}

	.listitem {
		font-size: 14px;
		display: flex;
		flex-direction: column;
		padding: 10px 5%;
		border-bottom: 1px solid #ddd;

		.top {
			display: flex;
			justify-content: space-between;

			.textleft {
				width: 80%;
				white-space: nowrap;
				overflow: hidden;
				text-overflow: ellipsis;
			}

			.righttips {
				color: red;
			}

			.green {
				color: green;
			}
		}

		.time {
			font-size: 12px;
			color: #ccc;
			margin-top: 5px;
		}

		.email {
			color: #000;
			margin: 2px 0;
		}
	}
</style>